﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ManageEbook.ascx.cs"
    Inherits="NLLSite.Administrator.UserControl.ManageEbook" %>
<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>
<script type="text/javascript" src="../../ckfinder/ckfinder.js"></script>
<script type="text/javascript">
    function BrowseServer() {
        // You can use the "CKFinder" class to render CKFinder in a page:
        var finder = new CKFinder();
        finder.basePath = '../../ckfinder/'; // The path for the installation of CKFinder (default = "/ckfinder/").
        finder.selectActionFunction = SetFileField;
        finder.popup();

        // It can also be done in a single line, calling the "static"
        // popup( basePath, width, height, selectFunction ) function:
        // CKFinder.popup( '../', null, null, SetFileField ) ;
        //
        // The "popup" function can also accept an object as the only argument.
        // CKFinder.popup( { basePath : '../', selectActionFunction : SetFileField } ) ;
    }

    // This is a sample function which is called when a file is selected in CKFinder.
    function SetFileField(fileUrl) {
        document.getElementById('ctl00_ContentPlaceHolderCenter_ManageEbook1_txtImage').value = fileUrl;
        //Element ID = Ten class usercontrol + 1 + ID cua text box.
    }

    function BrowseServerFile() {
        // You can use the "CKFinder" class to render CKFinder in a page:
        var finder = new CKFinder();
        finder.basePath = '../../ckfinder/'; // The path for the installation of CKFinder (default = "/ckfinder/").
        finder.selectActionFunction = SetFileFieldFile;
        finder.popup();

        // It can also be done in a single line, calling the "static"
        // popup( basePath, width, height, selectFunction ) function:
        // CKFinder.popup( '../', null, null, SetFileField ) ;
        //
        // The "popup" function can also accept an object as the only argument.
        // CKFinder.popup( { basePath : '../', selectActionFunction : SetFileField } ) ;
    }

    // This is a sample function which is called when a file is selected in CKFinder.
    function SetFileFieldFile(fileUrl) {
        document.getElementById('ctl00_ContentPlaceHolderCenter_ManageEbook1_txtFile').value = fileUrl;
        //Element ID = Ten class usercontrol + 1 + ID cua text box.
    }
</script>
<div class="box box-100">
    <div class="boxin">
        <div class="header">
            <h3>
                Quản lý Ebook</h3>
        </div>
        <div style="padding: 18px;">
            <!--<form class="basic" action="" method="post" enctype="multipart/form-data"><!-- Default basic forms -->
            <div class="inner-form">
                <asp:Panel ID="Panel2" runat="server" Visible="False">
                    <table>
                        <tr>
                            <td>
                                Tên Ebook:
                            </td>
                            <td>
                                <asp:TextBox ID="txtName" runat="server" Width="250px"></asp:TextBox>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Đường dẫn ảnh:
                            </td>
                            <td>
                                <asp:TextBox ID="txtImage" runat="server" AutoPostBack="True" Width="250px"></asp:TextBox>
                                <input type="button" value="Browse Server" onclick="BrowseServer();" class="altbutton" />
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td valign="top">
                                Miêu tả:
                            </td>
                            <td>
                                <CKEditor:CKEditorControl ID="CKEditor1" runat="server" Width="600px"></CKEditor:CKEditorControl>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Đường dẫn file:
                            </td>
                            <td>
                                <asp:TextBox ID="txtFile" runat="server" AutoPostBack="True" Width="250px"></asp:TextBox>
                                <input type="button" value="Browse Server" onclick="BrowseServerFile();" class="altbutton" />
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                                &nbsp;
                                <asp:Label ID="Label1" runat="server" ForeColor="Red"></asp:Label>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                                &nbsp;
                                <asp:Button ID="btnSave" runat="server" Text="Lưu lại" OnClick="btnSave_Click" 
                                    CssClass="altbutton" />
                                <asp:Button ID="txtCancel" runat="server" Text="Hủy bỏ" 
                                    OnClick="txtCancel_Click" CssClass="altbutton" />
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
                <asp:Panel ID="Panel1" runat="server">
                    <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" OnCheckedChanged="CheckBox1_CheckedChanged" />
                    <asp:Button ID="btnRemove" runat="server" Text="Xóa" OnClick="btnRemove_Click" 
                        CssClass="altbutton" OnClientClick="javascript:return confirm('Bạn có muốn xóa?')"/>
                    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
                        Text="Thêm mới" CssClass="altbutton" />
                    <br />
                    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                        CellPadding="4" DataKeyNames="ID" DataSourceID="LinqDataSource1" EnableModelValidation="True"
                        ForeColor="#333333" GridLines="None" 
                        OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="920px" 
                        AllowSorting="True">
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                        <Columns>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:CheckBox ID="cbxDelete" runat="server" />
                                </ItemTemplate>
                                <ItemStyle Width="50px" />
                            </asp:TemplateField>
                            <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                                SortExpression="ID" Visible="False" />
                            <asp:BoundField DataField="Title" HeaderText="Ebook" SortExpression="Title">
                                <HeaderStyle HorizontalAlign="Left" />
                                <ItemStyle Width="500px" HorizontalAlign="Left" />
                            </asp:BoundField>
                            <asp:TemplateField HeaderText="Ảnh" Visible="False">
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("ImageUrl") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Miêu tả" Visible="False">
                                <ItemTemplate>
                                    <asp:Label ID="Label2" runat="server" Text='<%# Eval("Description") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="File" Visible="False">
                                <ItemTemplate>
                                    <asp:Label ID="Label3" runat="server" Text='<%# Eval("FileUrl") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:CommandField SelectText="Sửa" ShowSelectButton="True" >
                            <ItemStyle Width="100px" />
                            </asp:CommandField>
                        </Columns>
                        <EditRowStyle BackColor="#999999" />
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    </asp:GridView>
                    <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="DAL_Class.NLLDataContext"
                        TableName="Ebooks">
                    </asp:LinqDataSource>
                </asp:Panel>
            </div>
        </div>
    </div>
</div>
